---
category: Array
created: '2020-04-19'
title: Get the average of an array
updated: '2021-10-13'
---

**JavaScript version**

```js average.js
const average = (arr) => arr.reduce((a, b) => a + b, 0) / arr.length;
```

**TypeScript version**

```ts average.ts
const average = (arr: number[]): number => arr.reduce((a, b) => a + b, 0) / arr.length;
```
